<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script type="text/javascript">
			function fun1(){
				var df = document.createDocumentFragment();
				for(var i=0;i<5;i++){
					var text = document.createElement("div");//1
					text.innerHTML="div的文字"+(i+1);//2
					text.setAttribute("style","color: red;")
					df.appendChild(text);//3
				}	
				var con = document.getElementById("con");//4
				con.appendChild(df);//4
			}
			function fun2(){
				var img = document.createElement("img");
				img.setAttribute("src","img/off.png");
				img.setAttribute("width","100px");
				var con = document.getElementById("con");//3
				con.appendChild(img);
			}
			function fun3(){
				var text = document.querySelector("#con>div");
				text.parentNode.removeChild(text);
			}
		</script>
	</head>
	<body>
		<button type="button" onclick="fun1()">添加文字</button>
		<button type="button" onclick="fun2()">添加图片</button>
		<button type="button" onclick="fun3()">删除第一个文字</button>
		<button type="button" onclick="fun4()">删除最后一个图</button>
		<div id="con"></div>
	</body>
</html>
